<template>
  <el-card class="announcement-container" shadow="never">
    <div slot="header" class="announcement-title">
      公告
    </div>
    <div class="announcement-ranking">
      <ul>
        <li v-for="(i, index) in announcementList" :key="i.id">
          <span class="rankNum">{{ index + 1 }}</span>
          <a class="list-title" @click="GoannouncementDetail(i)">{{
            i.announcement_title
          }}</a>
        </li>
      </ul>
    </div>
  </el-card>
</template>

<script>
export default {
  props: {},
  components: {},
  data() {
    return {
      // 限制和页数
      limit: 3,
      page: 1,
      // 公告列表
      announcementList: []
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    // 获取公告列表
    this.$nextTick(() => {
      this.getAnnouncementList()
    })
  },
  methods: {
    // 获取公告列表
    async getAnnouncementList() {
      const { limit, page } = this
      const res = await this.$API.announcement.GetAnnouncement(limit, page)
      if (res.status == 200) {
        this.announcementList = res.data.payload
      }
    },
    // 进入公告详情页
    GoannouncementDetail(announcement) {
      this.$router.push({
        name: 'AnnouncementDetail',
        params: {
          id: announcement.id
        }
      })
    }
  }
}
</script>

<style scoped>
.announcement-container {
  width: 90%;
  margin-left: auto;
  margin-bottom: 20px;
  box-shadow: 0px 0px 53px -12px rgba(0, 0, 0, 0.1);

  /* border-radius: 16px; */
}
.announcement-title {
  font-size: 14px;
  color: #888888;
}
.announcement-ranking {
  width: 100%;
  /* margin-top: 20px; */
}

.announcement-ranking ul {
  list-style: none;
  padding: 0;
}

.announcement-ranking li {
  display: flex;
  /* justify-content: space-between; */
  /* align-items: center; */
  margin-bottom: 15px;
  font-size: 14px;
}
.rankNum {
  color: #9090ab;
}
.announcement-ranking .list-title {
  margin-left: 10px;
  color: #888888;
}
.list-title {
  color: #888888;
  cursor: pointer;
}
.list-title:hover {
  color: #0077fa;
}
</style>
